﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace 第二课堂评审系统.Models
{
    public class ProjectConfig : IEntityTypeConfiguration<Project>
    {
        public void Configure(EntityTypeBuilder<Project> builder)
        {
            builder.ToTable("T_Project");
            builder.Property(p=>p.Name).HasMaxLength(30);
            builder.Property(p => p.Direction).HasMaxLength(20);
            builder.Property(p => p.Description).HasMaxLength(200);
            builder.Property(p => p.FileUrl).HasMaxLength(100);
            builder.HasOne(p => p.Partnar).WithOne(s=>s.project).HasForeignKey<Project>(p=>p.Id);//项目与小组一对一映射
            builder.HasMany(p => p.OperationTimes).WithOne(s=>s.Project);
        }
    }
}
